#!/usr/bin/env python3
# -*- coding: UTF-8 -*-

"""
@author: JoeyZhou
@Tool: PyCharm
@Date: 2020/2/15 10:30 AM
@desc: 封装拍机堂APP登录方法
"""

import json
from base.requests_base import RequestsBase
from common.sql_query import SqlQuery


class LoginView(RequestsBase):
    def __init__(self):
        super().__init__()
        account = SqlQuery().query_account(env='uat', username='吴彦祖')

        self.url = "http://uat-sj-gateway.aihuishou.com/sj-api/auth/login"

        self.data = {
            "userName": account[0],
            "passWord": account[1]
        }

        self.headers = {
            'Accept': 'application/json',
            'Connection': 'keep-alive',
            'Version': '1.50.0',
            'User-Agent': 'OPTapp/1.30.0 (com.aihuishou.OPTapp.E; build:912; iOS 12.4.0) Alamofire/4.9.0',
            'Platform': 'ios', 'Device-ID': 'EF047AF2-DACA-4BB4-95B3-DD585429C3D5',
            'App-ID': 'pjt042401'
        }

    def login(self)->dict:
        """
        封装登录接口
        :return:
        """
        res = self.send_post(url=self.url, headers=self.headers, data=self.data)
        return res


if __name__ == '__main__':
    lv = LoginView()
    print(lv.login())
